package com.dixiang.framework.http;

import java.util.Map;
import android.app.Activity;
import android.content.Context;
import android.util.Log;

import com.dixiang.framework.common.QJNetUICallback;
import com.dixiang.framework.config.SystemConfig;
import com.dixiang.framework.network.IResult;
import com.dixiang.framework.network.Net;
import com.dixiang.framework.network.URLHandler;
import com.dixiang.framework.utils.Utils;
import com.google.gson.reflect.TypeToken;

public class HttpAccess {

	public static <T extends IResult> String getDataObject(Activity activity,
			String url, String parameters, TypeToken typeToken,
			QJNetUICallback callback) {
		Net.fetch(activity.getApplicationContext(), url , parameters, typeToken, callback);
		return "";
	}
	
	public static <T extends IResult> String getDataObject(Activity activity,
			String url, String parameters, TypeToken typeToken,
			QJNetUICallback callback ,String flg) {
		Net.fetch(activity.getApplicationContext(), url , parameters, typeToken, callback , flg);
		return "";
	}

	public static <T extends IResult> String getCheckData(Context activity,
			String parameters, TypeToken typeToken,
			QJNetUICallback callback) {
		String url = SystemConfig.DATA_VERSION;
		Net.fetch(activity.getApplicationContext(), url , parameters, typeToken, callback);
		return "";
	}

	public static <T extends IResult> String getLocalData(Context activity,
			String url, String parameters, TypeToken typeToken,
			QJNetUICallback callback) {
		if (Utils.isStringEmpty(url)) {
			url = SystemConfig.DATA_LOCALDATA;
		}
		Net.fetch(activity.getApplicationContext(), url, parameters, typeToken, callback);
		
		return "";
	}

	public static <T extends IResult> String postDataObject(Activity activity,
			String url, Map<String, Object> map, TypeToken typeToken,
			QJNetUICallback callback) {
		Net.fetch(activity.getApplicationContext(), url, map, typeToken, callback);
		return "";
	}

	public static <T extends IResult> String getBookingList(Activity activity,
			String url, String parameters, TypeToken typeToken,
			QJNetUICallback callback, String tokenParam) {
		if (Utils.isStringEmpty(url)) {
			url = SystemConfig.DATA_BOOKING_LIST;
		}
		url = url + tokenParam;
		Net.fetch(activity.getApplicationContext(), url, parameters, typeToken, callback);
		return "";
	}

	public static <T extends IResult> String getBookingDetail(
			Activity activity, String url, String parameters,
			TypeToken typeToken, QJNetUICallback callback, String tokenParam) {
		url = url + tokenParam;
		Net.fetch(activity.getApplicationContext(), url, parameters, typeToken, callback);
		return "";
	}
}
